<%--@elvariable id="flag" type=""--%>
<%--@elvariable id="storeName" type=""--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="com.delivery.www.util.PageSupport" %>
<html>
<head>
    <title>店铺</title>
    <style>
        div {
            position: absolute;
            top: 30%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
        }

        table {
            display: inline-block;
        }

        table, tr, th, td {
            border: 1px solid #5fbdcb;
        }

        table {
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<div>
    <form id="form" action="${pageContext.request.contextPath}/store.do?method=allStore" method="post">
        <label>
            <input type="text" name="method" value="allStore" hidden>
        </label>
        <span>店铺名：</span>
        <label for="storeName"></label><input type="text" name="storeName" id="storeName" value="${storeName}">
        <label for="flag"></label><input type="text" id="flag" value="${flag}" hidden>
        <input type="submit" id="button" value="查询"><br>
    </form>
    <table>
        <tr>
            <th>店铺名</th>
            <th>店铺菜品数</th>
            <th>店铺评论</th>
            <th>店铺简介</th>
            <th>店铺完成订单数</th>
            <th></th>
            <th></th>
        </tr>
        <%--@elvariable id="stores" type="java.util.List"--%>
        <c:forEach var="store" items="${stores}">
            <tr>
                <td>
                        ${store.storeName}
                </td>
                <td>
                        ${store.dishNum}
                </td>
                <td>
                        ${store.commentNum}
                </td>
                <td>
                        ${store.introduce}
                </td>
                <td>
                        ${store.processOrderNum}
                </td>
                <td>
                    <a href="DishPage.jsp?storeId=${store.storeId}">进入</a>
                </td>
                <td>
                    <a href="CommentPage.jsp?storeId=${store.storeId}">查看评论</a>
                </td>
            </tr>
        </c:forEach>
    </table>
    <br>
    <a href="${pageContext.request.contextPath}/store.do?method=allStore&currentPageNo=1&storeName=${storeName}">首页</a>
    <c:if test="${PageSupport.currentPageNo>1}">
        <a href="${pageContext.request.contextPath}/store.do?method=allStore&currentPageNo=${PageSupport.currentPageNo-1}&storeName=${storeName}">上一页</a>
    </c:if>
    <c:if test="${PageSupport.currentPageNo<PageSupport.totalPageCount}">
        <a href="${pageContext.request.contextPath}/store.do?method=allStore&currentPageNo=${PageSupport.currentPageNo+1}&storeName=${storeName}">下一页</a>
    </c:if>
    <a href="${pageContext.request.contextPath}/store.do?method=allStore&currentPageNo=${PageSupport.totalPageCount}&storeName=${storeName}">尾页</a><br>
    <a href="HomePage.jsp">返回</a>
</div>
<script src="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
<script>
    let element = document.querySelector('#flag');
    let element1 = document.querySelector('#button');
    if (element.value === "") {
        element1.click();
    }
</script>
</body>
</html>
